﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;

namespace Coot
{
    public class GenericPhoto
    {
        private string src;
        private string cap;
        private int w;
        private int h;

        public string Source
        {
            get { return src; }
            set { src = value; }
        }

        public string Caption
        {
            get { return cap; }
            set { cap = value; }
        }

        public int Width
        {
            get { return w; }
            set { w = value; }
        }

        public int Height
        {
            get { return h; }
            set { h = value; }
        }


        public GenericPhoto(string source, string caption, int width, int height)
        {
            src = source;
            cap = caption;
            w = width;
            h = height;
        }
    }

    public class GenericPhotoCollection : List<GenericPhoto>
    {
        public GenericPhotoCollection()
        {

        }

        public GenericPhotoCollection(StringCollection sources, StringCollection captions, StringCollection widths, StringCollection heights)
        {
            for (int n = 0; n < sources.Count; n++)
            {
                this.AddPhoto(sources[n], captions[n], int.Parse(widths[n]), int.Parse(heights[n]));
            }
        }

        public void AddPhoto(string source, string caption, int width, int height)
        {
            this.Add(new GenericPhoto(source, caption, width, height));
        }

        public GenericPhoto GetRandomPhoto()
        {
            Random rnd = new Random();

            return this[rnd.Next(this.Count - 1)];
        }

        public StringCollection GetSources()
        {
            StringCollection collection = new StringCollection();

            for (int n = 0; n < this.Count; n++)
            {
                collection.Add(this[n].Source);
            }

            return collection;
        }

        public StringCollection GetCaptions()
        {
            StringCollection collection = new StringCollection();

            for (int n = 0; n < this.Count; n++)
            {
                collection.Add(this[n].Caption);
            }

            return collection;
        }

        public StringCollection GetWidths()
        {
            StringCollection collection = new StringCollection();

            for (int n = 0; n < this.Count; n++)
            {
                collection.Add(this[n].Width.ToString());
            }

            return collection;
        }

        public StringCollection GetHeights()
        {
            StringCollection collection = new StringCollection();

            for (int n = 0; n < this.Count; n++)
            {
                collection.Add(this[n].Height.ToString());
            }

            return collection;
        }
    }
}
